﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Concurrent;
using ExORMDesginer.Models;
using System.ComponentModel.Composition;
using DatabaseSchemaReader.DataSchema;
using ExtendPropertyLib;
using ExORMDesginer.Plugin;

namespace ExORMDesginer.Services
{
    /// <summary>
    /// 数据库构架元数据信息服务
    /// </summary>
    [Export("DatabaseMeta")]
    public class DatabaseMetaService : IService
    {
        private Dictionary<string,DbEntity> Tables;
        /// <summary>
        /// 表元数据(构架)信息
        /// </summary>
        public SerializableObservableCollection<DbEntity> TableMetas
        {
            set;
            get;
        }

        /// <summary>
        /// 数据库构架信息
        /// </summary>
        public DatabaseSchema Schema { set; get; }


        /// <summary>
        /// 取得服务处理后的元数据字典
        /// </summary>
        /// <returns></returns>
        public object GetContext()
        {
            return Tables;
        }

        /// <summary>
        /// 数据库类型
        /// </summary>
        public SqlType SQLType { set; get; }
        /// <summary>
        /// 连接字符串
        /// </summary>
        public string ConnectionString { set; get; }
        /// <summary>
        /// 服务处理方法
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        public object Process(params object[] args)
        {
            Tables = args[0] as Dictionary<string, DbEntity>;
            return null;
        }
    }
}
